package com.zatech.cgnci.project.service.impl;

import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zatech.cgnci.project.base.enums.ResponseCodeEnum;
import com.zatech.cgnci.project.base.exception.GlobalException;
import com.zatech.cgnci.project.dto.CgnciUnearnedPremiumReserveLedgerDTO;
import com.zatech.cgnci.project.entity.CgnciUnearnedPremiumReserveLedgerDO;
import com.zatech.cgnci.project.mapper.CgnciBusinessInsuranceMapper;
import com.zatech.cgnci.project.mapper.CgnciOutstandingClaimsReserveLedgerMapper;
import com.zatech.cgnci.project.mapper.CgnciUnearnedPremiumReserveLedgerMapper;
import com.zatech.cgnci.project.service.CgnciProvisionRegisterService;
import com.zatech.cgnci.project.service.CgnciUnearnedPremiumReserveLedgerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zatech.cgnci.project.vo.CgnciRiskVO;
import com.zatech.cgnci.project.vo.CgnciUnearnedPremiumReserveLedgerVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 未到期保费准备金台账表 服务实现类
 * </p>
 *
 * @author Generator
 * @since 2025-01-23
 */
@Service
public class CgnciUnearnedPremiumReserveLedgerServiceImpl extends ServiceImpl<CgnciUnearnedPremiumReserveLedgerMapper, CgnciUnearnedPremiumReserveLedgerDO> implements CgnciUnearnedPremiumReserveLedgerService {
    private final static String OUTSTANDING = "1";
    private final static String UNEARNED = "2";
    @Resource
    private CgnciProvisionRegisterService provisionRegisterService;
    @Override
    public IPage<CgnciUnearnedPremiumReserveLedgerVO> pageData(CgnciUnearnedPremiumReserveLedgerDTO queryDTO) {
        return this.baseMapper.page(queryDTO.toPage(), queryDTO);
    }

    @Override
    public ExcelWriter export(CgnciUnearnedPremiumReserveLedgerDTO queryDTO) {
        switch (queryDTO.getReserveTypeCode()) {
            case OUTSTANDING:
                return provisionRegisterService.OutstandingClaimsReserveLedger(null,queryDTO);
            case UNEARNED:
                return provisionRegisterService.UnearnedPremiumReserveLedger(null,queryDTO);
            default:
                throw new GlobalException(ResponseCodeEnum.HTTP_REQUEST_SERVICE_ERROR);
        }
    }

}
